{include file="public/header" /}
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
	<span class="c-gray en">&gt;</span> 权限管理
	<span class="c-gray en">&gt;</span> 管理员列表
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="pd-20"> 
	<div class="cl pd-5 bg-1 bk-gray mt-20">
		<span class="l">
			<a href="javascript:;" onclick="datadel('{:url('Auth/admin_del')}')" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
			<a class="btn btn-primary radius" data-title="添加管理员" _href="" onclick="new_open('添加管理员','{:url('Auth/admin_add')}')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加管理员</a>
		</span>
	<span class="r">共有数据：<strong id="count">{:count($list)}</strong> 条</span>  
 </div>
	<div class="mt-20">
		<form action="{:url('rule')}" method="post" id='sort-form'>
			<table class="table table-border table-bordered table-bg table-hover table-sort">
				<thead>
					<tr class="text-c">
						<th width="25"><input type="checkbox" name="" value=""></th>
						<th width="50">ID</th>
						<th width="150">账号</th>
						<th>昵称</th>
						<th>角色</th>
						<th width="140">登录时间</th>
						<th width="120">登录次数</th>
						<th width="120">操作</th>
					</tr>
				</thead>
				<tbody>
					{foreach name="list" item="v"}
						<tr class="text-c" id="tr{$v.id}">
							{if condition="$v.id gt 1"}
								<td><input type="checkbox" value="{$v.id}" name="del[]"></td>
							{else/}
								<td></td>
							{/if}
							<td>{$v.id}</td>
							<td>{$v.username}</td>
							<td>{$v.nickname}</td>
							<td>{$v.roles|default='没有角色'}</td>
							<td>
								{if condition="$v.login_time"}
									{$v.login_time|date="Y-m-d H:i:s"}
								{else/}
									从未登录
								{/if}
							</td>
							<td>{$v.login_num}</td>
							<td>
								<a style="text-decoration:none" class="btn btn-success ml-5" 
								onClick="article_add('管理员编辑','{:url('admin_add',array('id'=>$v['id']))}')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>
								{if condition="$v.id gt 1"}
								<a style="text-decoration:none" class="btn btn-danger ml-5" onClick="data_del(this,'{:url('admin_del')}','{$v.id}')" href="javascript:;" title="删除">
								<i class="Hui-iconfont">&#xe6e2;</i></a>
								{/if}
								
							</td>
						</tr>
					{/foreach}
				</tbody>
			</table>
			<div class="page">
				{:htmlspecialchars_decode($list->render())}
			</div>
		</form>
	</div>
</div>

<script type="text/javascript">
/*管理员-添加*/
function article_add(title,url,w,h){
	layer_show(title,url,w,h);
}

/*-删除*/
function member_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.post("{:url('admin_del')}",{id:id},function(data){
			if(data.status == 'y'){
				//删除自己
				$(obj).parents("tr").remove();
				$("#count").text($("#count").text()-1);
				layer.msg(data.info,{icon:1,time:1000});
			}else{
				layer.msg(data.info,{icon:2,time:1000});
			}
		},'json');

	});
}
//批量删除
function datadel(){
 var id='';	
 $("input[name='del[]']:checked").each(function(){
 	id += $(this).val()+',';
 });

 if(id == ''){
 	layer.msg('必须选择哦!',{icon:2,time:1000});
 	return false;
 }
 layer.confirm('确认要删除吗？',function(index){
 	$.post("{:url('admin_del')}",{id:id},function(data){
			if(data.status == 'y'){
				var count = $("#count").text(),i=0;
				$("input[name='del[]']:checked").each(function(){
 					$(this).parents('tr').remove();
 					i++;
 				});
				$("#count").text(count = $("#count").text()-i);
				layer.msg(data.info,{icon:1,time:1000});
			}else{
				layer.msg(data.info,{icon:2,time:1000});
			}
	});
 });
}
</script>
{include file="public/footer" /}
